-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Docs: Fix flutter build command for Android flavors #12257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
/gcbrun |
Visit the preview URL for this PR (updated for commit 3165433): https://flutter-docs-prod--pr12257-fix-android-flavors-command-rj9gzarb.web.app |
@reidbaker, can you please review this? It looks like there has been a technical change and the command we are using in the original documentation for Android Flavors no longer works as expected. |
@reidbaker @antfitch Could you please review this when you have time? |
@Hassnaa9 still researching over here! I hope to have confirmation that this is not a code bug by Friday. |
@mboetger can you take a look since I am out sick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for bringing this to our attention! I added a few comments.
- **To build a release version for a specific flavor:** | ||
```console title="console" | ||
$ flutter build --flavor <flavor_name> --target <path_to_main.dart_file> | ||
``` | ||
Example (assuming your `staging` flavor has a `main_staging.dart` entry point): | ||
```console title="console" | ||
$ flutter build apk --release --flavor staging -t lib/main_staging.dart | ||
``` | ||
or to build an app bundle: | ||
```console title="console" | ||
$ flutter build appbundle --release --flavor staging -t lib/main_staging.dart | ||
``` | ||
|
||
```console title="console" | ||
$ flutter run --flavor staging | ||
``` | ||
The `--target` flag is used to specify the entry point file for the flavor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tutorial does not talk at all about creating different target dart files - so I think it's confusing to add the extra detail about the targets. Can we just focus updating the flutter build
documentation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example: | ||
- **To build a release version for a specific flavor:** | ||
```console title="console" | ||
$ flutter build --flavor <flavor_name> --target <path_to_main.dart_file> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still doesn't have apk or appbundle so this would fail
Example: | ||
```console title="console" | ||
$ flutter run --flavor staging | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should try to make the changes as minimal as possible to fix the issue, something like this would work:
-
In the console, navigate to the
flavors_example
directory and enter the following command:$ flutter (run | build <subcomand>) --flavor <flavor_name>
(run | build <subcommand>)
: Replace this with one of the
following:run
: Run the app in debug mode.build
: Build either an apk or an appbundle.<subcommand>
: Eitherapk
orappbundle
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on board with this more subtle change as well.
@antfitch - As far as I can tell, this is not a bug - the |
Fixes #12248
This pull request updates the Launch a flavor section of the Android flavors documentation to correct the command for building a specific flavor.
Preview:
https://flutter-docs-prod--pr12257-fix-android-flavors-command-rj9gzarb.web.app/deployment/flavors
The Problem:
The current documentation at src/content/deployment/flavors.md incorrectly states that the flutter build command can be used with only the --flavor flag. As of recent Flutter updates, this syntax is invalid and results in an error... (and so on)